package org.example.JVM.ByteCode.Handler;

import org.example.JVM.ByteCode.Type.ClassFile;
import org.example.JVM.ByteCode.Type.U2;

import java.nio.ByteBuffer;

/**
 * @description:
 * @author: farprt
 * @create: 2022-11-13 13:48
 **/
public class VersionHandler implements BaseByteCodeHandler {
    @Override
    public int order() {
        return 1;
    }

    @Override
    public void read(ByteBuffer codeBuf, ClassFile classFile) throws Exception {
        //读取副版本号
        U2 minorVersion = new U2(codeBuf.get(), codeBuf.get());
        classFile.setMinor_version(minorVersion);
        //读取主版本号
        U2 majorVersion = new U2(codeBuf.get(), codeBuf.get());
        classFile.setMajor_version(majorVersion);

    }
}